# coding=utf-8
from ToolsConfig import *

if 1 > 2:
    from SpecialFunciton.BlueFoxSystem import BlueFoxServerSystem

    blueFoxServerSystem = BlueFoxServerSystem

molangNames = {}


def ChangeBlockEntityMolangFromServerToAllClient(posDim, molangName, value):
    # type:(Tuple[int,int,int,int],str,float) -> None
    """
    从服务端修改所有客户端某一位置的方块实体里的molang值
    :param posDim: 方块实体的坐标与维度
    :param molangName: molang名称
    :param value: molang值
    :return:
    """
    blueFoxServerSystem.BroadcastToAllClient('ChangeBlockEntityMolang', {
        'molangName': molangName, 'value': value, 'posDim': posDim
    })


def ChangeBlockEntityMolangFromServerToClient(playerId, posDim, molangName, value):
    # type:(Union[int,str],Tuple[int,int,int,int],str,float) -> None
    """
    从服务端修改某一客户端某一位置的方块实体里的molang值
    :param posDim: 方块实体的坐标与维度
    :param molangName: molang名称
    :param value: molang值
    :param playerId: 玩家id
    :return:
    """
    blueFoxServerSystem.NotifyToClient(playerId, 'ChangeBlockEntityMolang', {
        'molangName': molangName, 'value': value, 'posDim': posDim
    })


def RegisterMolang(molangName, defaultValue=0.0):
    """
    注册并获取molang查询字段
    :param molangName: molang名称,无需query.mod.
    :param defaultValue: 默认值
    :return:
    """
    name = 'query.mod.' + molangName
    molangNames[name] = defaultValue
    return name


def RegisterMolangWithNameSpace(molangName, defaultValue=0.0):
    """
    注册并获取molang查询字段,自带命名空间，使用时需要在前部加入MOD_NAME_molangName
    :param molangName: molang名称
    :param defaultValue: 默认值
    :return:
    """
    return RegisterMolang('{}_{}'.format(MOD_NAME, molangName), defaultValue)
